from fastapi import Depends
from sqlalchemy.ext.asyncio import AsyncSession
from ..configuration.DataBaseConfiguration import get_session
from ..models import User
from ..mapper import UserMapper


class UserService:

    def __init__(self, session: AsyncSession):
        self.session = session
        self.userMapper = UserMapper(session)

    @classmethod
    async def create(cls, session: AsyncSession = Depends(get_session)):
        return cls(session)

    async def get_user_by_id(self, user_id: int) -> User | None:
        return await self.userMapper.get_user_by_id(user_id)

    async def create_user(self, username: str, password: str, role: str = "admin") -> User | None:
        return await self.userMapper.get_user_by_id(1)
